package gsm

import (
	"encoding/base64"
	"encoding/hex"
	"github.com/tjfoc/gmsm/sm2"
	"github.com/tjfoc/gmsm/x509"
)

func ParseSm2PublicKeyByBase64(v string) (p *sm2.PublicKey, err error) {
	b, err := base64.StdEncoding.DecodeString(v)
	if err != nil {
		return
	}
	return x509.ParseSm2PublicKey(b)
}

func ParseSm2PublicKeyByHex(v string) (p *sm2.PublicKey, err error) {
	b, err := hex.DecodeString(v)
	if err != nil {
		return
	}
	return x509.ParseSm2PublicKey(b)
}
